from goods_info.models import *
from rest_framework.serializers import ModelSerializer
from rest_framework import serializers
class AttachmentsSerializer(ModelSerializer):
    '''

    附件和图片的序列化
    '''
    #附件或者图片的文件名
    file_name=serializers.CharField(source='a_file.name',read_only=True)
    #附件或者图片的url地址
    file_url=serializers.CharField(source='a_file.url',read_only=True)
    #附件的文件类型
    type_display=serializers.CharField(source='get_a_type_display',read_only=True)
    class Meta:
        model=AttachmentModel
        fields=['id','a_file','a_type','file_url','file_name','type_display']
